ARG ROS_DISTRO=humble
FROM luxonis/depthai-ros:${ROS_DISTRO}-latest

ENV DEBIAN_FRONTEND=noninteractive

ENV WS=/OAK_WS
RUN mkdir -p /OAK_WS/src
COPY ./ .$WS/src/ros2_oak_ffc_sync
RUN rosdep update
RUN apt update && apt install wget
RUN wget http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-depthai-ros-msgs/ros-humble-depthai-ros-msgs_2.11.2-1jammy.20250617.215228_amd64.deb && \
    apt install ./ros-humble-depthai-ros-msgs_2.11.2-1jammy.20250617.215228_amd64.deb && rm ./ros-humble-depthai-ros-msgs_2.11.2-1jammy.20250617.215228_amd64.deb
RUN wget http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-depthai-bridge/ros-humble-depthai-bridge_2.11.2-1jammy.20250617.231404_amd64.deb && \
    apt install ./ros-humble-depthai-bridge_2.11.2-1jammy.20250617.231404_amd64.deb && rm ./ros-humble-depthai-bridge_2.11.2-1jammy.20250617.231404_amd64.deb
RUN wget http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-depthai-descriptions/ros-humble-depthai-descriptions_2.11.2-1jammy.20250617.230931_amd64.deb && \
    apt install ./ros-humble-depthai-descriptions_2.11.2-1jammy.20250617.230931_amd64.deb && rm ./ros-humble-depthai-descriptions_2.11.2-1jammy.20250617.230931_amd64.deb
RUN cd .$WS/ && rosdep install --from-paths src --ignore-src  -y
RUN cd $WS/ && . /opt/ros/${ROS_DISTRO}/setup.sh && MAKEFLAGS="-j1 -l1" colcon build

RUN echo "if [ -f ${WS}/install/setup.zsh ]; then source ${WS}/install/setup.zsh; fi" >> $HOME/.zshrc
RUN echo 'eval "$(register-python-argcomplete3 ros2)"' >> $HOME/.zshrc
RUN echo 'eval "$(register-python-argcomplete3 colcon)"' >> $HOME/.zshrc
RUN echo "if [ -f ${WS}/install/setup.bash ]; then source ${WS}/install/setup.bash; fi" >> $HOME/.bashrc

ENTRYPOINT [ "/OAK_WS/src/ros2_oak_ffc_sync/entrypoint.sh" ]
CMD ["zsh"]